<?php
namespace app\controller\api\cms;

use app\BaseController;
use app\model\cms\NavModel;
class Nav extends BaseController
{

    public function index(){

        $uniacid = $_GET['i'];
        $list = NavModel::where([ 'uniacid'=>$uniacid, 'status'=>'1', 'pid'=>0 ])->order('sort_order')->select();

        foreach( $list as &$item ){

            $item['children'] = NavModel::where(['status'=>'1','pid'=>$item->id])->order('sort_order')->select();

        }
        
        return json( $list );
        
    }

    public function bottom(){

        $list = NavModel::where(['status'=>'1','pid'=>0, 'bottom'=>1])->order('sort_order')->select();

        foreach( $list as &$item ){

            $item['children'] = NavModel::where(['status'=>'1','pid'=>$item->id, 'bottom'=>1])->order('sort_order')->select();

        }
        
        return json( $list );
        
    }
}